package com.course_design.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.course_design.entity.Class;
import com.course_design.entity.School;
import com.course_design.service.SchoolSerevice;

@Controller
public class SchoolController {
	@Autowired
	private SchoolSerevice schoolService;
	@RequestMapping("/queryAllSchool")
	@ResponseBody
	public Msg queryAllSchool() {
		List<School> schools=schoolService.queryAllSchool();
		return Msg.success("OK").add("schools", schools);
	}
	@RequestMapping(value="/addSchool",method=RequestMethod.POST)
	@ResponseBody
	public Msg queryClassBySchoolId(School school) {
			if(schoolService.querySchoolByCode(school.getCode())) {
				return Msg.error("error");
			}
			if(schoolService.addSchool(school)) {
				return Msg.success("OK");
			}else {
				return Msg.error("error");
			}
		
	}
	
}
